//
//  MVPPresenter.m
//  Demo_MVP
//
//  Created by 陈冰 on 2020/3/8.
//  Copyright © 2020 ChenBing. All rights reserved.
//

#import "MVPPresenter.h"
#import "MVPModel.h"

@implementation MVPPresenter

- (instancetype)init {
    self = [super init];
    if (self) {
        [self loadData];
    }
    return self;
}

- (void)loadData {
    NSArray *tempArray =
    @[
      @{@"name":@"AAAA",@"imageUrl":@"http://CC",@"num":@"9"},
      @{@"name":@"BBB",@"imageUrl":@"http://James",@"num":@"9"},
      @{@"name":@"CCC",@"imageUrl":@"http://Gavin",@"num":@"9"},
      @{@"name":@"DDD",@"imageUrl":@"http://Cooci",@"num":@"9"},
      @{@"name":@"EEE",@"imageUrl":@"http://Dean ",@"num":@"9"},
//      @{@"name":@"FFF",@"imageUrl":@"http://CC",@"num":@"9"},
//      @{@"name":@"GGG",@"imageUrl":@"http://James",@"num":@"9"},
//      @{@"name":@"QQQ",@"imageUrl":@"http://Gavin",@"num":@"9"},
//      @{@"name":@"WWW",@"imageUrl":@"http://Cooci",@"num":@"9"},
//      @{@"name":@"RRR",@"imageUrl":@"http://CC",@"num":@"9"},
//      @{@"name":@"TTT",@"imageUrl":@"http://James",@"num":@"9"},
//      @{@"name":@"YYY",@"imageUrl":@"http://Gavin",@"num":@"9"},
//      @{@"name":@"UUU",@"imageUrl":@"http://Cooci",@"num":@"9"},
//      @{@"name":@"III",@"imageUrl":@"http://CC",@"num":@"9"},
//      @{@"name":@"OOO",@"imageUrl":@"http://James",@"num":@"9"},
//      @{@"name":@"PPP",@"imageUrl":@"http://Gavin",@"num":@"9"},
//      @{@"name":@"SSS",@"imageUrl":@"http://Cooci",@"num":@"9"},
//      @{@"name":@"HHH",@"imageUrl":@"http://Dean ",@"num":@"9"}
    ];
    for (NSInteger i = 0; i< tempArray.count; i++) {
        MVPModel *m = [MVPModel modelWithDict:tempArray[i]];
        [self.dataArray addObject:m];
    }
}

- (NSMutableArray *)dataArray {
    if (!_dataArray) {
        _dataArray = [NSMutableArray new];
    }
    return _dataArray;
}

- (void)didClickAddBtnWithNum:(NSString *)num indexPath:(NSIndexPath *)indexPath {
    MVPModel *m = self.dataArray[indexPath.row];
    m.num = num;

    if (self.delegate && [self.delegate respondsToSelector:@selector(reloadDataForIndexPath:)]) {
        [self.delegate reloadDataForIndexPath:indexPath];
    }
}

@end
